/*
    This file is part of SQLiteGTK, written by Aly Hirani

    SQLiteGTK is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    SQLiteGTK is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with SQLiteGTK.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __OPT_MANAGER_H__
#define __OPT_MANAGER_H__

#include "include.h"

typedef struct _OptManagerOption OptManagerOption;
typedef struct _OptManagerOptionGroup OptManagerOptionGroup;
typedef gboolean(*opt_manager_option_callback)(OptManagerOption *opt, const gchar *arg);

struct _OptManagerOption
{
	gchar *short_arg;
	gchar *long_arg;
	gboolean args;
	gboolean default_opt;
	opt_manager_option_callback callback;
	gpointer user_data;
};

struct _OptManagerOptionGroup
{
	OptManagerOption *default_opt;
	GHashTable *args;
};

/**
 * Creates a new OptManagerOptionGroup
 */
OptManagerOptionGroup* opt_manager_option_group_new();

/**
 * Frees a OptManagerOptionGroup
 */
void opt_manager_option_group_free(OptManagerOptionGroup *group);

/**
 * Appends the given OptManagerOption to the given OptManagerOptionGroup
 */
void opt_manager_option_group_add_option(OptManagerOptionGroup *group, OptManagerOption *option);

/**
 * Parses the given commandline arguments with the options setup in the OptManagerOptionGroup
 * @returns TRUE if parsing was successful. FALSE if parsing failed for some reason
 */
gboolean opt_manager_parse(const OptManagerOptionGroup *opt_manager, const gint argc, const gchar *argv[]);

#endif /* __OPT_MANAGER_H__ */

